﻿<UserControl x:Class="eNursePHR.userInterfaceLayer.AnnotationControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="clr-namespace:eNursePHR.userInterfaceLayer"
   
    >
    <UserControl.Resources>
        <ui:StatementContentConverter x:Key="StatementContentConverter" />
        <ui:StatementContentTypeConverter x:Key="StatementContentTypeConverter" />
        <ui:ValidContentConverter x:Key="ValidContentConverter" />
        <ui:AnnotationToolTipConverter x:Key="AnnotationToolTipConverter" />

    </UserControl.Resources>
        <Expander x:Name="exAnnotation" IsExpanded="False"
         Background="{StaticResource BlueTheme}"
         Padding="5">
        <Expander.Header>
            <TextBlock Text="Information acquisition" FontSize="13" FontWeight="UltraBold" />
        </Expander.Header>


        <ListView x:Name="lvAnnotation" Grid.Row="2" 
           IsSynchronizedWithCurrentItem="True"
				SelectionChanged="lvAnnotation_SelectionChanged"
				  ItemContainerStyle="{StaticResource GreenItemContainer}"
				  Style="{DynamicResource ListViewStyleInformationAcquired}"
		       >
            <ListView.Resources>

                <SolidColorBrush x:Key="ListBorder" Color="#FF7F9DB9"/>
                <Style x:Key="ListViewStyleInformationAcquired" TargetType="{x:Type ListView}">
                    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
                    <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
                    <Setter Property="BorderThickness" Value="1"/>
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
                    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
                    <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListView}">
                                <StackPanel>
                                    <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" 
							BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1">
                                        <ScrollViewer Padding="{TemplateBinding Padding}" Focusable="false">
                                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        </ScrollViewer>
                                    </Border>
                                    <TextBlock Text="No information acquired" x:Name="tbEmpty" Visibility="Collapsed" ToolTip="Use annotation highlights/markup to gather information about diagnoses and interventions that are relevant for coding via the taxonomy" />
                                </StackPanel>
                                <ControlTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Path=Items.Count,

            RelativeSource={RelativeSource Self}}" Value="0">

                                        <Setter TargetName="tbEmpty" Property="Visibility" 

              Value="Visible" />
                                        <Setter TargetName="Bd" Property="Visibility" Value="Collapsed" />

                                    </DataTrigger>
                                    <Trigger Property="IsEnabled" Value="false">
                                        <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                    </Trigger>
                                    <Trigger Property="IsGrouping" Value="true">
                                        <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListView.Resources>

            <!--<ListView.View>
			
				<GridView>-->


            <!--<GridViewColumn Header="Authors" Width="120">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<StackPanel>
									<ComboBox x:Name="cbAuthors" ItemsSource="{Binding Authors, Mode=OneWay}" SelectedIndex="0"  />
								   <TextBlock x:Name="tbAuthorsNotSpecified" Text="No authors specified" Visibility="Collapsed" />
								</StackPanel>
								
								<DataTemplate.Triggers>
									<DataTrigger Binding="{Binding Path=Authors.Count}" Value="0">
											<Setter Property="Visibility" TargetName="cbAuthors" Value="Collapsed" />
										<Setter Property="Visibility" TargetName="tbAuthorsNotSpecified" Value="Visible" />
									</DataTrigger>
								</DataTemplate.Triggers>
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>
					
					
					<GridViewColumn Header="Created" Width="130">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock  Text="{Binding CreationTime, Mode=OneWay}"  />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>
					
					<GridViewColumn Header="Last modification" Width="130">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding LastModificationTime, Mode=OneWay}"  />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>

					<GridViewColumn Header="Content" Width="130">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding ., Mode=OneWay, Converter={StaticResource HighlightTextConverter}}"  />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>-->

            <!--<GridViewColumn Width="130">
		
						<GridViewColumn.CellTemplate>
						
							<DataTemplate>
								
									<TextBlock x:Name="tbAnnotationContent" Text="{Binding Path=Anchors[0].Contents[0].OuterXml, Converter={StaticResource StatementContentConverter}}"  />
				
				<DataTemplate.Triggers>
					<DataTrigger Binding="{Binding Path=Anchors[0].Contents[0].OuterXml, Converter={StaticResource StatementContentTypeConverter}}" Value="Diagnosis">
						<Setter Property="Foreground" TargetName="tbAnnotationContent" Value="{StaticResource DiagnosisColor}" />
					</DataTrigger>

					<DataTrigger Binding="{Binding Path=Anchors[0].Contents[0].OuterXml, Converter={StaticResource StatementContentTypeConverter}}" Value="Intervention">
						<Setter Property="Foreground" TargetName="tbAnnotationContent" Value="{StaticResource InterventionColor}" />
					</DataTrigger>

				</DataTemplate.Triggers>
				
						
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>




				</GridView>
			</ListView.View>-->

            <ListView.ItemTemplate>
                <DataTemplate>

                    <StackPanel Orientation="Horizontal">
                        <StackPanel.BitmapEffect>
                            <OuterGlowBitmapEffect GlowSize="0" />
                        </StackPanel.BitmapEffect>
                        <Image x:Name="imgInvalidContent" Height="6" VerticalAlignment="Center" Source="/Images/ERROR.png" Visibility="Collapsed" Margin="0,0,5,0" />
                        <TextBlock TextWrapping="Wrap" x:Name="tbAnnotationContent" 
						    MaxWidth="200" 
							FontWeight="UltraBold"
						    Text="{Binding Path=Anchors[0].Contents[0].OuterXml, Converter={StaticResource StatementContentConverter}}"
						    ToolTip="{Binding ., Converter={StaticResource AnnotationToolTipConverter}}"  />



                        <!--<TextBlock TextWrapping="Wrap" x:Name="tbAnnotationContent" 
						    MaxWidth="200" 
						    Text="{Binding XPath=Statement[1]/@Content}"
						    DataContext="{Binding Path=Anchors[0].Contents[0]}"
						     />-->

                    </StackPanel>

                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=Anchors[0].Contents[0].OuterXml, Converter={StaticResource StatementContentTypeConverter}}" Value="Diagnostic">

                            <Setter Property="Foreground" TargetName="tbAnnotationContent" Value="{StaticResource DiagnosisColor}" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding Path=Anchors[0].Contents[0].OuterXml, Converter={StaticResource StatementContentTypeConverter}}" Value="Interventional">
                            <Setter Property="Foreground" TargetName="tbAnnotationContent" Value="{StaticResource InterventionColor}" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding Path=Anchors[0].Contents[0].OuterXml, Converter={StaticResource StatementContentTypeConverter}}" Value="Disease">
                            <Setter Property="Foreground" TargetName="tbAnnotationContent" Value="{StaticResource DiseaseColor}" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding Path=Anchors[0].Contents[0].OuterXml, Converter={StaticResource StatementContentTypeConverter}}" Value="Medication">
                            <Setter Property="Foreground" TargetName="tbAnnotationContent" Value="{StaticResource MedicationColor}" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding ., Converter={StaticResource ValidContentConverter}}" Value="False">
                            <Setter Property="Visibility" TargetName="imgInvalidContent" Value="Visible" />
                        </DataTrigger>


                    </DataTemplate.Triggers>


                </DataTemplate>
            </ListView.ItemTemplate>

        </ListView>

    </Expander>

</UserControl>
